package com.singfan.common.util;

/**
 * 操作系统工具类
 * Author: HanSongHe
 * Date: 2015-07-27 14:47
 * Desc:
 */
public class SystemUtil {
    private static String osName = null;
    private static boolean WINDOWS = false;
    private static boolean MAC = false;
    private static boolean LINUX = false;

    static {
        osName = System.getProperty("os.name");
        if(osName != null){
            osName = osName.toLowerCase();
            if(osName.startsWith("windows")){
                WINDOWS = true;
            }
            else if(osName.startsWith("mac")){
                MAC = true;
            }
            else if(osName.startsWith("linux")){
                LINUX = true;
            }
        }
    }

    /**
     * 是否为Windows系统
     * @return  true:是   false:否
     */
    public static boolean isWindowsOs(){
        return WINDOWS;
    }

    /**
     * 是否为Mac系统
     * @return  true:是   false:否
     */
    public static boolean isMacOs(){
        return MAC;
    }

    /**
     * 是否为Linux系统
     * @return  true:是   false:否
     */
    public static boolean isLinux(){
        return LINUX;
    }

    /**
     * 获取操作系统名字
     * @return 操作系统名字
     */
    public static String getOSName(){
        return osName;
    }
}
